<template>
    <div class="pad">
        <!-- table start -->
            <tableDataEl
                :page.sync="page"
                :pageSize.sync="pageSize"
                :tableData="tableData.list"
                :tableLabel="tableLabel"
                :pageCount="tableData.rows"
                height="89vh"
                v-loading="loading"
                @handleDetail="handleDetail"
            />
        <!-- table end -->

        <!-- dialog start -->
        <el-dialog
            :visible.sync="isShowDialog"
            center
            title="物料信息"
            width="40%"
            v-el-drag-dialog
        >
            <el-table
                :data="detailData.supplement"
                border
                height="242"
                v-loading="detailLoading"
            >
                <el-table-column
                    label="物料名称"
                    prop="name"
                    align="center"
                    width="250"
                />
                <el-table-column
                    label="配给数量"
                    prop="ration"
                    align="center"
                />
                <el-table-column
                    label="剩余库存"
                    prop="materiel_stock"
                    align="center"
                />
                <el-table-column
                    label="需补充量"
                    prop="supplement"
                    align="center"
                />
            </el-table>
        </el-dialog>
        <!--  dialog end -->
    </div>
</template>

<script>
    import tableDataEl from '@/views/Setup/common/table'
    export default {
        name: "throughdownList",
        components: {
            tableDataEl
        },
        data () {
            return {
                page: 1,
                pageSize: 8,
                tableData: {},
                tableLabel: [
                    {
                        label: '运营商名称',
                        prop: 'company'
                    },
                    {
                        label: '负责人',
                        prop: 'leader'
                    },
                    {
                        label: '电话',
                        prop: 'phone'
                    },
                    {
                        label: '取消理由',
                        prop: 'reason',
                        nowrap: true
                    },
                    {
                        label: '物料信息',
                        detail: true,
                        btnText: '查看',
                        methodName: 'handleDetail'
                    },
                    {
                        label: '申请时间',
                        prop: 'create_time'
                    },
                    {
                        label: '审核时间',
                        prop: 'audit_time'
                    },
                    {
                        label: '审核人',
                        prop: 'audit_person'
                    }
                ],
                loading: false,
                isShowDialog: false,
                detailLoading: false,
                detailData: []
            }
        },
        methods: {
            async init () {
                this.loading = true;
                let res = await this.api.log_c_adoptList({page: this.page, pageSize: this.pageSize});
                res.code ? this.tableData = res.data : this.$message(res.msg);
                this.loading = false;
            },
            async handleDetail (...value) {
                this.isShowDialog = true;
                this.detailLoading = true;
                let res = await this.api.qxDetail({id: value[1]['id']});
                res.code ? this.detailData = res.data : this.$message(res.msg);
                this.detailLoading = false;
            }
        },
        mounted () {
            this.init();
        },
        watch: {
            page () {
                this.init();
            },
            pageSize () {
                this.init();
            }
        }
    }
</script>

<style scoped>
    .pad {
        padding: 10px;
    }
</style>
